### Makefile --- 
## Time-stamp: <2008-10-19 23:55:20 root>
## Author: root@localhost.localdomain
## Version: $Id: Makefile,v 0.0 2008/10/03 14:59:35 root Exp $
## Keywords: 
## X-URL: 

.SUFFIXES: .c
.PHONY: clean all

LIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lpthread
INCS=-I/usr/local/mysql/include/mysql

CC=gcc -g
CXX=g++
# CFLAGS=-O -Wall -DUNIX -DDEBUG -DTRACE_FILE='"./trace"' -D__PATH__='"$(PWD)/"'

EDF=

all: ehomed prepare.sh bakehome.sh
	sh prepare.sh
	cp bakehome.sh /usr/local/bin/
	echo "Compile finnished!"

OBJECTS=func.o log.o wrapsock.o signal.o heart.o db.o config.o hashtable_itr.o hashtable.o hashtable_utility.o defense.o server.o auth.o mutex.o
OBJS=main.o $(OBJECTS)

ehomed: common.h $(OBJS)
	$(CC) -o $@ $(OBJS) $(INCS) $(LIBS)

main.o: main.c
auth.o: auth.c
defense.o: defense.c
func.o: func.c
log.o: log.c
wrapsock.o: wrapsock.c
signal.o: signal.c
heart.o: heart.c
db.o: db.c
server.o:server.c
config.o: config.c
mutex.o: mutex.c
# debug.o: debug.c
hashtable.o: hashtable.c
hashtable_itr.o: hashtable_itr.c
hashtable_utility.o:hashtable_utility.c
testdb.o: testdb.c
testdefen.o: testdefen.c
testlog.o: testlog.c
client.o: client.c
	$(CC) -c $< $(INCS) $(LIBS) 

CLIENT_OBJS=client.o func.o
client: $(CLIENT_OBJS)
	$(CC) -o client $(CLIENT_OBJS) $(INCS) $(LIBS)

TEST_DB_OBJS=testdb.o db.o config.o func.o hashtable_itr.o hashtable.o hashtable_utility.o defense.o signal.o wrapsock.o heart.o log.o
testdb: $(TEST_DB_OBJS) common.h
	$(CC) -o testdb $(TEST_DB_OBJS) $(INCS) $(LIBS)

TEST_DEFEN_OBJS=testdefen.o db.o config.o log.o func.o hashtable_itr.o hashtable.o hashtable_utility.o defense.o signal.o wrapsock.o heart.o
testdefen: $(TEST_DEFEN_OBJS) common.h
	$(CC) -o testdefen $(TEST_DEFEN_OBJS) $(INCS) $(LIBS)

TEST_LOG=testlog.o $(OBJECTS)
testlog: $(TEST_LOG) common.h
	$(CC) -o testlog $(TEST_LOG) $(INCS) $(LIBS)

.c:
	$(CC) -o $@ $< $(CFLAGS) $(INCS) $(LIBS)

.c.o:
	$(CC) -c $< $(CFLAGS) $(INCS) $(LIBS)

clean:
	-rm *.o ehomed

### Makefile ends here
